import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import legacy from '@vitejs/plugin-legacy'
import { fileURLToPath, URL } from 'node:url'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  return {
    base : mode === 'production' ? '/openlayers-demo' : undefined,
    server: {
      host: true,
      port: 8765
    },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
        '@types': fileURLToPath(new URL('./types', import.meta.url)),
      }
    },
    plugins: [vue(), vueJsx(), legacy()],
  }
})
